IF OBJECT_ID('dbo.GetPostAwardManagers') IS NOT NULL
BEGIN
    DROP PROCEDURE dbo.GetPostAwardManagers
    IF OBJECT_ID('dbo.GetPostAwardManagers') IS NOT NULL
        PRINT '<<< FAILED DROPPING PROCEDURE dbo.GetPostAwardManagers >>>'
    ELSE
        PRINT '<<< DROPPED PROCEDURE dbo.GetPostAwardManagers >>>'
END
go
-- =======================================================================
-- Procedure Name: dbo.GetPostAwardManagers
--
-- Author:      Kevin Cashman, Parallax Consulting LLC
--
-- Create date: 5/24/2007
--
-- Description: Returns list of PostAwardManagers from UDF table
--
-- Parameters:  None
--              
-- Returns:     INT, 0=Success, -1=Error
--
-- SampleCall:
-- EXECUTE dbo.GetPostAwardManagers()
--
--------------------------------------------------------------------------
-- Date        Initials  Modification
--------------------------------------------------------------------------
-- 7/11/07     KC        Created
-- 8/15/07     KC        Permissions
-- 9/28/07     KC        Fixed FwkDomainUserId
-- 11/2/07     KC        Added @Institution
--
-- =======================================================================
CREATE PROCEDURE dbo.GetPostAwardManagers
     (@Institution            INT=NULL)
AS
BEGIN
     /*  Returned Fields for Dropdown
     --------------------------------
     PostAwardManagerId       INT
     PostAwardManagerName     VARCHAR             
     PostAwardManager         VARCHAR
     */

     -- Initial Settings
     SET NOCOUNT ON
     
     -- Declare Local Variables
     DECLARE   @Error            INT,
               @RowCount         INT

     -- Result Query    
     SELECT DISTINCT PostAwardManagerId AS PostAwardManagerId,
               PostAwardManagerName AS PostAwardManagerName,
               PostAwardManagerCode AS PostAwardManager
     FROM      dbo.AgrAgreement_Info AI
     WHERE     (@Institution IS NULL OR AI.InstitutionId = @Institution) AND
               PostAwardManagerCode IS NOT NULL AND PostAwardManagerCode != ''
     ORDER BY PostAwardManagerName
     
     SELECT @Error=@@ERROR,@RowCount=@@ROWCOUNT
     IF @Error!=0
          RETURN -1

     -- Return Success
     RETURN 0
     
END
go

IF OBJECT_ID('dbo.GetPostAwardManagers') IS NOT NULL
    PRINT '<<< CREATED PROCEDURE dbo.GetPostAwardManagers >>>'
ELSE
    PRINT '<<< FAILED CREATING PROCEDURE dbo.GetPostAwardManagers >>>'
go

GRANT EXECUTE ON dbo.GetPostAwardManagers TO InsightReport,Insight
go
